package com.qtest.qandroid.service.UserServiceImp;

import com.qtest.qandroid.dao.CourseDao;
import com.qtest.qandroid.entity.Course;
import com.qtest.qandroid.entity.Result;
import com.qtest.qandroid.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseDao courseDao;

    @Override
    public Result<List<Course>> selectAllCourseFromOneStudent(String userId) {
        Result<List<Course>> result = new Result<>();
        List<Course> list =courseDao.selectAllCourseFromOneStudent(userId);
        if (list.size()>0){
            result.setNum("1");
            result.setData(list);
            result.setMessage("请求成功");
        }else{
            result.setNum("0");
            result.setMessage("请求无结果");
        }
        return result;
    }

    @Override
    public Course isThereCorrectCode(String joinNumber,String userId) {

        return courseDao.isThereCorrectCode(joinNumber,userId);

    }

    @Override
    public void insertSelectCourse(String userId, String courseId, String name) {
        courseDao.insertSelectCourse(userId, courseId, name);
    }

    @Override
    public void createNewCourse(Course course) {
        courseDao.createNewCourse(course);

    }

    @Override
    public void deleteCourse(String courseId) {
        courseDao.deleteCourse(courseId);
    }

    @Override
    public void deleteCourse2(String userId, String courseId) {
        courseDao.deleteCourse2(userId,courseId);
    }


}
